<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 动物类
        function Animal(look){
            this.look=look;
        }
        Animal.prototype.eat=function(){
            return '动物吃东西...';
        }
        // 两栖类
        function Amphibious(color,look){
            this.color=color;
            Animal.call(this,look);
        }
        Amphibious.prototype.waterInto=function(){
            return '入水';
        }
        Amphibious.prototype.waterOut=function(){
            return '出水';
        }
        Amphibious.prototype.__proto__=Animal.prototype;
        // 哺乳类
        function  Lactation(color,leg,look){
            this.color=color;
            this.leg=leg;
            Animal.call(this,look);
        }
        Lactation.prototype=Object.create(Animal.prototype);
        Lactation.prototype.constructor=Lactation;
        Lactation.prototype.creep=function(){
            return '爬行';
        }
        // 鸟类
        function Bird(color,wingspan,look){
            this.color=color;
            this.wingspan=wingspan;
            Animal.call(this,look);
        }
        Object.assign(Bird.prototype,Animal.prototype);
        Bird.prototype.fly=function(){
            return '飞行';
        }
        // 虎类
        function Tiger(type,speed,color,leg,look){
            this.type=type;
            this.speed=speed;
            Lactation.call(this,color,leg,look);
        }
        Tiger.prototype.__proto__=Lactation.prototype;
        Tiger.prototype.hunt=function(){
            return "老虎捕猎";
        }
        // 鹰类 vision视力
        function Eagle(type,speed,vision,color,wingspan,look){
            this.type=type;
            this.speed=speed;
            this.vision=vision;
            // 借用父类的属性
            Bird.call(this,color,wingspan);
        }
        Eagle.prototype.__proto__=Bird.prototype;
        Eagle.prototype.hunt=function(){
            return "老鹰捕猎";
        }
        // 两栖动物实例
        let amphibious1=new Amphibious("褐色","圆形");
        console.log(amphibious1,amphibious1.eat(),amphibious1.waterInto(),amphibious1.waterOut());
        // 老虎实例
        let tiger1=new Tiger("东北虎","54km/h","黄色",4,'雄伟');
        console.log(tiger1,tiger1.eat(),tiger1.creep(),tiger1.hunt());
        // 老鹰实例
        let eagle1=new Eagle("苍鹰","80km/h",10,"灰色","2米","庞大");
        console.log(eagle1,eagle1.eat(),eagle1.fly(),eagle1.hunt());
    </script>
</body>
</html>